<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
.ban{
    width: 1200px;
    height: 700px;
    background-color: #ffffff;
    margin:30px auto;
    box-shadow: 5px 5px 10px;
   
}
.ae{
    width: 150px;
    height: 250px;
    background-color: #f3f3f3;
    text-align: center;
    line-height: 25px;
    float: left;
    margin: 20px 10px;
    
}
    .ae img{
        width: 100px;
        height: 150px;
        
     }   
     
     span{
        display: block;
     }
     .jia{
        width: 100px;
        height: 35px;
        background-color: red;
        text-align: center;
        line-height: 35px;
        margin: auto;
     }
     .wei{
        width: 700px;
        margin-left: 50px;
        float: left;
     }
     .df{
        width: 145px;
        height: 92px;
        margin: auto;
        background-color: #ffffff;
     }
     ul{
        width: 400px;
        height: 600px;
        background-color: #fff;
        float: right;
        box-shadow: 2px 2px 10px;
        margin: 20px 20px;
     }
     li{
        list-style: none;
        margin: 30px 20px;
        position: relative;
        display: flex;
        
     }
     .in{
        position: absolute;
        left: 0;
        top: 30px;
     }
     li img{margin:0 25px;
    }
     .sp{
        position: absolute;
        right: 15px;
        top: 45px;
     }
    </style>
</head>

<body>
    <div class="ban">
        <div class="wei">
            <!-- <div class="ae"> -->
                <!-- <img src="./img/1.jpg_Q75.jpg" alt="">
                <div class="df">
                    <p>时装</p>
                <span>100</span>
                <div class="jia">加入购物车</div>
                </div> -->
            <!-- </div> -->
        </div>
        <ul>
            <p>购物车(0)</p>
            <!-- <li>
                <input type="checkbox" class="in">
                <img src="./img/1.jpg_Q75.jpg" alt="" width="60px">
                <div>
                    <p>时装</p>
                <span>¥100</span>
                <button>-</button>
                <input type="text" value="1"size="5">
                <button>+</button>
            <span class="sp">删除</span>
                </div>
            </li> --> 
        </ul>
    </div>
</body>

</html>
<script>
    let data=[
            {id: "1001",
            imgurl: "./img/1.jpg_Q75.jpg",
            title: "女包",
            money: 100,
            num: "1",
        },
        {id: "1002",
            imgurl: "img/1.webp",
            title: "女包女包",
            money: 100,
            num: "1",
        },
        {id: "1003",
            imgurl: "img/1.webp",
            title: "女包女",
            money: 100,
            num: "1",
        },
        {id: "1004",
            imgurl: "img/1.webp",
            title: "女包女包",
            money: 100,
            num: "1",
        },
        {id: "1005",
            imgurl: "img/1.webp",
            title: "女包女包女",
            money: 100,
            num: "1",
        },
        {id: "1006",
            imgurl: "img/1.webp",
            title: "女包女包女包包女",
            money: 100,
            num: "1",
        },
        {id: "1007",
            imgurl: "img/1.webp",
            title: "女包女包女包包",
            money: 100,
            num: "1",
        },
        ]
        var oAe=document.querySelector(".wei")
        function render(){
            var str=''
        data.forEach(function(item,index){
            str+=
                `<div class="ae">
                <img src=${item.imgurl} alt="">
                <div class="df">
                <p>${item.title}</p>
                <span>${item.money}</span>
                <div class="jia">加入购物车</div>
                </div>
                </div>
                </div>
                `
            })
            oAe.innerHTML=str
        }
        render()
        var oUl=document.querySelector("ul")
        
       var oJa= document.querySelectorAll(".ae .df .jia")
    for(var i=0;i<oJa.length;i++){
        oJa[i].onclick=function(){
        let li=document.createElement('li')
        data.forEach(function(item,index){
            li.innerHTML=`<input type="checkbox" class="in">
                <img src="${item.imgurl}" alt="" width="60px">
                <div clas="dv">
                    <p>${item.title}</p>
                <span>¥${item.money*item.num}</span>
                <button class="add">-</button>
                <input type="text" value="10"size="5" calss="put"  >
                <button class="daa">+</button>
            <span class="sp">删除</span>
                </div>`
                oUl.appendChild(li)
    })
    let  dw= document.querySelectorAll('ul>li')
        let add=document.querySelector(".add")
        let inp=document.querySelector(".put")
        add.onclick=function(){
           var num= inp.value
           num--
           inp.value=num
        }
}

    }
    

</script>